package com.yu.shortlink.admin.config;

/**
 * @Author yushiwang
 * @Date 2024/4/10 21:47
 * @PackageName:com.yu.shortlink.admin.config
 * @ClassName: UserConfiguration
 * @Version 1.0
 */


import com.yu.shortlink.admin.common.biz.user.UserTransmitFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;


/**
 * 用户配置自动装配
 */

@Configuration
public class UserConfiguration {
 /**
     * 用户信息传递过滤器
     */

    @Bean
    public FilterRegistrationBean<UserTransmitFilter> globalUserTransmitFilter(StringRedisTemplate stringRedisTemplate) {
        FilterRegistrationBean<UserTransmitFilter> registration = new FilterRegistrationBean<>();
        registration.setFilter(new UserTransmitFilter(stringRedisTemplate));
        registration.addUrlPatterns("/*");
        registration.setOrder(0);
        return registration;
    }
}
